#include <vector>
#include <iostream>

using namespace std;

vector<vector<int>> yangHuiTriangle(int level) {
  vector<vector<int>> result {{1}};

  for (int l = 1; l < level; ++l) {
    vector<int> tmp(l + 1, 0);

    for (int j = 0; j < l + 1; ++j) {
      if (j == 0 || j == l) {
        tmp[j] = 1;
      }
      else {
        tmp[j] = result[l - 1][j - 1] + result[l - 1][j];
      }
    }

    result.push_back(tmp);
  }

  return result;
}

int main(int argc, char const *argv[])
{
  /* code */
  auto result = yangHuiTriangle(5);

  for (auto v : result) {
    for (int n : v) {
      cout << n << " ";
    }

    cout << endl;
  }
  return 0;
}
